package com.example.wechat.login.config;

import com.tencentcloudapi.asr.v20190614.AsrClient;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 腾讯云语音API配置类
 */
@Configuration
public class TencentSpeechConfig {

    @Value("${tencent.cloud.speech.secretId}")
    private String secretId;

    @Value("${tencent.cloud.speech.secretKey}")
    private String secretKey;

    @Value("${tencent.cloud.speech.region}")
    private String region;



    /**
     * 创建腾讯云语音识别客户端
     */
    @Bean
    public AsrClient asrClient() {
        // 实例化一个认证对象，入参需要传入腾讯云账户secretId，secretKey
        Credential credential = new Credential(secretId, secretKey);

        // 实例化一个http选项，可选，没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("asr.tencentcloudapi.com");

        // 实例化一个client选项，可选，没有特殊需求可以跳过
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);

        // 实例化要请求产品的client对象，clientProfile是可选的
        return new AsrClient(credential, region, clientProfile);
    }
}
